package com.hxzy.util;

import com.hxzy.entity.TbNewbeeMallAdminUser;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class SessionUtil {

    /**
     * 获取session中的用户信息
     *
     * @return User
     */
    public static TbNewbeeMallAdminUser getUser() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        return (TbNewbeeMallAdminUser) request.getSession().getAttribute("currentUser");
    }

    /**
     * 当前是否登录
     *
     * @return
     */
    public static boolean isLogin() {
        return null != SessionUtil.getUser();
    }



}
